home *** CD-ROM | disk | FTP | other *** search
- {* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- (c) TechInsite Pty. Ltd.
- PO Box 429, Abbotsford, Melbourne. 3067 Australia
- Phone: +61 3 9419 6456
- Fax: +61 3 9419 1682
- Web: www.techinsite.com.au
- EMail: peter_hinrichsen@techinsite.com.au
-
- Created: Jan 2000
-
- Notes: Wrapper a TDatabase component
-
- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
- unit tiDBConnection;
-
- interface
- uses
- Classes
- ,DB
- ,DBTables
- ;
-
- type
-
- TtiDBConnection = class( TObject )
- private
- FDatabase : TDatabase ;
- FSession : TSession ;
- function GetDatabaseName: string;
- public
- constructor create ;
- destructor destroy ; override ;
- property DatabaseName : string read GetDatabaseName ;
- end ;
-
- implementation
-
- // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- // *
- // * TtiDBConnection
- // *
- // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- // Create a TDatabase and TSession, then connect
- constructor TtiDBConnection.create;
- begin
- inherited Create ;
- FSession := TSession.Create( nil ) ;
- FSession.AutoSessionName := true ;
-
- FDatabase := TDatabase.Create( nil ) ;
- FDatabase.DatabaseName := 'DBMain' ;
- FDatabase.DriverName := 'INTRBASE' ;
- FDatabase.LoginPrompt := false ;
- FDatabase.Params.Add( 'SERVER NAME=adrs.gdb' ) ;
- FDatabase.Params.Add( 'USER NAME=SYSDBA' ) ;
- FDatabase.Params.Add( 'PASSWORD=masterkey' ) ;
- FDatabase.SessionName := FSession.Name ;
- FDatabase.Connected := true ;
- end;
-
- // Destroy the database and session
- //------------------------------------------------------------------------------
- destructor TtiDBConnection.destroy;
- begin
- FSession.Free ;
- FDatabase.Free ;
- inherited;
- end;
-
- // Return the database's name for connection to TQuery(s)
- function TtiDBConnection.GetDatabaseName: string;
- begin
- result := FDatabase.DatabaseName ;
- end;
-
- end.
-